package cn.tedu.csmall.product.controller;

import cn.tedu.csmall.product.ex.ServiceException;
import cn.tedu.csmall.product.pojo.param.AttributeTemplateAddNewParam;
import cn.tedu.csmall.product.service.AttributeTemplateService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apiguardian.api.API;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(tags = "属性模板的管理模块")
@RestController
@RequestMapping("/attribute-template")
public class AttributeTemplateController {

    @Autowired
    AttributeTemplateService service;

    @PostMapping("/add-new")
    @ApiOperation("添加属性模板")
    @ApiOperationSupport(order = 200)
    public String addNew(AttributeTemplateAddNewParam attributeTemplateAddNewParam){
        try {
            service.addNew(attributeTemplateAddNewParam);
            return "添加成功";
        }catch (ServiceException e){
            return e.getMessage();
        }catch (Throwable e){
            return "其他一些异常";
        }
    }
}
